package chat_server

import (
	"encoding/base64"
	"fmt"
)

type IMsg interface {
	Encode() string
}

type NameMsg struct {
	Name string
}

func (me *NameMsg) Encode() string {
	return fmt.Sprintf("NAME %s\n", base64.StdEncoding.EncodeToString([]byte(me.Name)))
}

type ChatMsg struct {
	Name string
	Words string
}

func (me *ChatMsg) Encode() string {
	return fmt.Sprintf("CHAT %s %s\n",
		base64.StdEncoding.EncodeToString([]byte(me.Name)),
		base64.StdEncoding.EncodeToString([]byte(me.Words)),
	)
}
